package com.qf.config;

import com.qf.consants.RabbitMQConstants;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    // 创建一个交换机
    @Bean
    public FanoutExchange goodsExchange(){
        System.out.println("RabbitMQConfig.goodsExchange");
        return new FanoutExchange(RabbitMQConstants.GOODS_EXCAHNGE,true,false);
    }

    // 创建一个队列
    @Bean
    public Queue goodsQueueEs(){
        return new Queue(RabbitMQConstants.GOODS_QUEUE_ES,true,false,false);
    }

    // 绑定
    @Bean
    public Binding goodsQueueEsTogoodsExchange(){
        return BindingBuilder.bind(goodsQueueEs()).to(goodsExchange());
    }
}
